#pragma once

#define BUTTON_NORMAL	0
#define BUTTON_HOVER	1
#define BUTTON_PUSHED	2
#define BUTTON_DISABLE	3

class CXPngButton : public CWindowImpl<CXPngButton>
{
public:
	CXPngButton(void);
	~CXPngButton(void);

	BEGIN_MSG_MAP_EX(CXPngButton)
		MESSAGE_RANGE_HANDLER(WM_MOUSEFIRST, WM_MOUSELAST, OnMouseMessage)
 		MSG_WM_LBUTTONDOWN(OnLButtonDown)
 		MSG_WM_LBUTTONUP(OnLButtonUp)
		MSG_WM_PAINT(OnPaint)
		MSG_WM_ERASEBKGND(OnEraseBkgnd)
		MSG_WM_MOUSEMOVE(OnMouseMove)
		MSG_WM_MOUSELEAVE(OnMouseLeave)
		MSG_WM_MOUSEHOVER(OnMouseHover)
	END_MSG_MAP()

	LRESULT OnMouseMessage(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
	LRESULT OnPaint(HDC);
	LRESULT OnEraseBkgnd(HDC);
	LRESULT OnMouseMove(WPARAM wParam, CPoint pt);
	LRESULT OnMouseHover(WPARAM wParam, CPoint pt);
	LRESULT OnMouseLeave();
	LRESULT OnLButtonDown(WPARAM wParam, CPoint pt);
	LRESULT OnLButtonUp(WPARAM wParam, CPoint pt);

	void Init();
	BOOL SubclassWindow(HWND hWnd);
	void SetButtonPng(const CString & str, int nStateCount);
	void SetText(const CString & str){m_strText = str;};
	void SetTooltip(const CString & str);

	CRect GetRect();
private:
	IXpng *			m_pPng;
	CString			m_strPngPath;
	int				m_nButtonTypeCount;
	int				m_nButtonState;
	CString			m_strText;

	CRect			m_rcClient;

	BOOL			m_bMouseLeave;
	BOOL			m_bButtonDown;

	CToolTipCtrl	m_tooltip;
	CString			m_strToolTip;
};
